//实现 Runnable, 重写 run, 使用匿名内部类
public class Demo4 {
    public static void main(String[] args) throws InterruptedException {
                             //此处针对 Runnable 定义匿名内部类，返回结果是一个 Runnable 的引用，把这个引用传入 Thread
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                while(true){
                    System.out.println("使用匿名类创建 Runnable 子类对象");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        });

        t.start();

        while(true){
            System.out.println("hello main");
            Thread.sleep(1000);
        }

    }
}
